<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>系统管理-菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
    <input type="hidden" id="id" name="id" value="${sysMenu.id}" />
    <input type="hidden" name="parentId" value="${sysMenu.parentId}" />
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;父级菜单</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" value="${sysMenu.parentMenuName!'无'}" readonly /></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;菜单类型</label>
        <div class="layui-input-block">
            <select class="form-control" name="menuType" lay-verify="required" lay-filter="menuType" id="menuType"></select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;菜单名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="menuName" value="${sysMenu.menuName}" placeholder="请输入菜单名称" lay-verify="required"  autocomplete="off" /></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12 menuTypeSelect menuTypeMlSelect menuTypeCdSelect">
        <label class="layui-form-label">
            <span class="red"></span>&nbsp;&nbsp;菜单图标</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="menuIcon" value="${sysMenu.menuIcon}" placeholder="请输入菜单图标" autocomplete="off" /></div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12 menuTypeSelect menuTypeCdSelect menuTypeAlSelect">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;菜单权限</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="permission" id="permission" value="${sysMenu.permission}" placeholder="请输入菜单权限" autocomplete="off" /></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12 menuTypeSelect menuTypeCdSelect">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;菜单连接</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="menuUrl" id="menuUrl" value="${sysMenu.menuUrl}" placeholder="请输入菜单连接" autocomplete="off" /></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;排序</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="sort" id="sort" value="${sysMenu.sort}" placeholder="请输入排序" lay-verify="required" autocomplete="off" /></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button></div>
    </div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['form', 'jquery', 'baseUtil', 'dialogUtil', 'pageUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
            dialogUtil = layui.dialogUtil,
            baseUtil = layui.baseUtil,
            pageUtil = layui.pageUtil;
            var menuType="${sysMenu.menuType!'1'}";
        changeMenuType(menuType);
        //监听下拉框
        form.on('select(menuType)', function(data){
            //1、目录，2、菜单，3、按钮
            changeMenuType(data.value);
        });
        function changeMenuType(value) {
            //1、目录，2、菜单，3、按钮
            $(".menuTypeSelect").hide();
            if("1"==value){
                $(".menuTypeMlSelect").show();
            }else if("2"==value){
                $(".menuTypeCdSelect").show();
            }else{
                $(".menuTypeAlSelect").show();
            }
        }
        pageUtil.initDict("sys_menu_type",
            function(dictData) {
                pageUtil.showDict($("#menuType"), pageUtil.aceeptDictContentList(dictData, "sys_menu_type"), "", menuType);
            });
        form.on('submit(submitBtn)',
            function(data) {
                var menuType=data.menuType;
                //1、目录，2、菜单，3、按钮
                if("2"==menuType) {
                    var permission = $("#permission").val();
                    if (permission == null || permission == "") {
                        dialogUtil.msg("请输入菜单权限");
                        return false;
                    }
                    var menuUrl = $("#menuUrl").val();
                    if (menuUrl == null || menuUrl == "") {
                        dialogUtil.msg("请输入菜单连接");
                        return false;
                    }
                }else if("3"==menuType) {
                    var permission = $("#permission").val();
                    if (permission == null || permission == "") {
                        dialogUtil.msg("请输入菜单权限");
                        return false;
                    }
                }
                var sort=$("#sort").val();
                if(sort == null || sort == ""){
                    dialogUtil.msg("请输入排序");
                    return false;
                }

                baseUtil.postMethodResult("/sysMenu/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });</script>
</body>

</html>